package com.jq.jqaicode.exception;

import com.jq.jqaicode.common.ResultUtils;
import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.guardrail.InputGuardrail;
import dev.langchain4j.guardrail.InputGuardrailResult;

/**
 * 护栏
 */
public class MyInputGuardrail implements InputGuardrail {

    @Override
    public InputGuardrailResult validate(UserMessage userMessage) {
        // 示例：敏感词拦截
        String ss=userMessage.singleText();
        if (true) {
            ResultUtils.runError("用户输入了敏感违规词，不会生成应用");
        }
        return success();
    }
}
